<%@ page contentType="text/html; charset=utf-8" language="java"  errorPage="" %>
<%@ page import="com.netscenery.yang.model.Env" %>
<%@ page import="com.netscenery.yang.model.Case" %>
<%@ page import="operate.OperateType"%>
<%@page import="offer.GetDataSource"%>
<%@page import="com.netscenery.yang.model.Node"%>
<%@page import="com.netscenery.yang.designer.MapInfo"%>
<%@page import="com.netscenery.yang.designer.FieldMap"%>
<%@page import="offer.SessionObj"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Case caseNote = new Case(new Env(),"MyCase");
//获取结点对象
Object itemNode = request.getAttribute("itemNode");
Object opType   = request.getAttribute("opType"); //获取操作对象
if( null != itemNode){
	caseNote = (Case)itemNode;
}
MapInfo mapInfo = caseNote.getMapInfo();
FieldMap fieldMap = null; 
boolean hasMimInfo = false;
for(int i = 0 ; i < mapInfo.getBasicFieldsNumber() ; i++){
   	fieldMap = mapInfo.getBasicField(i);
   	if(fieldMap.getFieldName().equalsIgnoreCase("mininfo")){
   		hasMimInfo = true;
   		break;
   	}
}
SessionObj sessionObj = (SessionObj)request.getSession().getAttribute("sessionObj");
String control_disabled = "";
if(!sessionObj.getModuleStatus().toString().equalsIgnoreCase("EDITING")){
 control_disabled ="disabled='disabled'";
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Case</title>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/items.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/subItems.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/Tab.css" />
    <script type="text/javascript"  src="<%=basePath%>jstree-v.pre1.0/_lib/jquery.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/StringUtil.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/IfFeature.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/Tab.js"></script>
</head>
<body class="body" >
<script type="text/javascript">
   function bodyLoad(){
    <% if( (null != itemNode) 
        &&  (!opType.toString().equalsIgnoreCase(OperateType.LOAD))){ %>
	<%   	if(opType.toString().equalsIgnoreCase(OperateType.ADD) 
	           || opType.toString().toString().equalsIgnoreCase(OperateType.MODIFY_INCLUDE_NAME)){ %>
	   		 	 //新增节点时，重新加载数
	   		 	 parent.reloadTreeWithNode(document.getElementById("nodeId").value);
   <%   	} %>
			 $("#opNoticeSpan").html("操作成功！");
   		 	 setTimeout(function(){$("#opNoticeSpan").html("")},3000);
   <% }%>  
   }
   $(document).ready(function(){
        $("#submitButton").click(function(){
	 	     $(":input").css("border-color","");
		     if($("#_name").val().trim().length == 0){
		        $("#_name").css("border-color","red");
		        alert("name 不能为空！");
		        return;
		     }
		     //名字验证
		     if(!nameVerify($("#_name").val().trim(),$("#_name"))){
		     	return;
		     }
		    
		     document.getElementById("CaseForm").submit(); 
		});
		 tabLaod();
		 load_Feature();
		 bodyLoad();
 	});
 	//用于保存节点中的If Feature name的列表 与IfFeature.js配合使用
 	var availableFeatures = "<%= GetDataSource.GetAvailableIfFeatureList((Node)itemNode)%>";
 	var currNodeFeatures  = "<%= GetDataSource.GetCurrNodeIfFeatureList((Node)itemNode)%>";
</script>
<!-- ***************************************** Tab Navigate Begin **************************************  -->
 <div class="navTitle" style="display:none;">
   <ul id="navTabTitle">
     <li id="mainContent_ico" onclick="showThis('mainContent')">Leaf Main Content</li>
     <li id="type_ico"><span onclick="showThis('type')">Type Edit</span><img onclick="closeTab('type')" class='TitleLiImg' width='10' height='16' src='<%=basePath %>/images/delete.png' /></li>
     <li id="mimInfo_ico"><span onclick="showThis('mimInfo')">MimInfo Edit</span><img onclick="closeTab('mimInfo')" class='TitleLiImg' width='10' height='16' src='<%=basePath %>/images/delete.png' /></li>
   </ul>
   <div style="clear:both;"></div>
 </div>
 <div id="mimInfo_tab"  style="display:none;padding:0px;margin:0px;max-height:560px;height:560px;">
 <iframe width="100%" id="MimInfo_Iframe" name="MimInfo_Iframe"  height=100% border="0" frameborder="0" src=""  ></iframe>
 </div>
 <!-- ***************************************** Tab Navigate End   **************************************  -->
 <div id="mainContent_tab" class="" style="padding:0px;margin:0px;">
 <!-- ****************************************************************************************************** -->
  <form id="CaseForm" method="post" action="<%=basePath %>CaseOpreateServlet" class="IndexFormStyle" >
   <input type="hidden"  id="nodeId" name="nodeId" value="<%=request.getAttribute("nodeId") %>"  />
   <div id="TableContent" class="tableContent" >
   	   <div class="itemTitle">
	           The Case [<%=caseNote.getName() %>] information  
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Indetifier:</span>
	     <input class="inputText" id="_name" name="_name" value="<%=caseNote.getName()==null?"":caseNote.getName()%>" />
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Status:</span>
	     <select style="width:305px;   height:23px; padding:1px;"  id="_status" name="_status">
          <% for(int i = 0 ; i < GetDataSource.getStatusList().length ; i++ ){ %>
          <%     if(caseNote.getStatus().getStatus().equalsIgnoreCase(GetDataSource.getStatusList()[i])){ %>  
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" selected="selected"><%=GetDataSource.getStatusList()[i] %></option>
          <%     }else{ %> 
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" ><%=GetDataSource.getStatusList()[i] %></option>   
          <%     }
             } %>
          </select>
	   </div>
	   <!-- ***********************If Feature HTML part     Begin *************************************** -->
	   <input type="hidden" id="featureParam" name="featureParam" value="" />
	   <div id="If_Feature_Content" class="itemDiv">
	       
	   </div>
	   <!-- ***********************If Feature HTML part     End ***************************************** -->
       <!--  
       <% if(hasMimInfo){ %>
       <div class="itemDiv">
		   <span class="textSpan">&nbsp;MimInfo:</span>
           <input type="button" id="_mimInfoEdit" value = "Edit MimInfo"  onclick="Show_MimIfoEdit()" />
	       <span class="notNullSpan">*</span>
	   </div>
	   <%} %>
	   -->
	   <div class="itemDiv">
	   	  <span class="textSpan">&nbsp;Description:</span><br/>
	      <textarea class="textArea"  id="description" name="description"><%=caseNote.getDescription()==null?"":caseNote.getDescription() %></textarea>
	   </div>

	   <div class="itemDiv">
	   	  <span class="textSpan">&nbsp;Reference:</span><br/>
	      <textarea class="textArea"  id="reference" name="reference"><%=caseNote.getReference()==null?"":caseNote.getReference() %></textarea>
	   </div>
   </div>
   <div id="submitContent" class="submitContent">
     <span id="opNoticeSpan" style="color:red;" ></span>
     <span class="textSpan">&nbsp;</span>
     <input type="button" <%=control_disabled %> id="submitButton" value="Apply"  />
   </div>
   </form> 
 <!-- ****************************************************************************************************** -->
 </div>
</body>
</html>